package com.meida.module.bus.provider.handler;

import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.interceptor.PageInterceptor;
import com.meida.common.mybatis.model.PageParams;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.module.bus.client.entity.BusTerm;
import com.meida.module.bus.client.entity.BusTestpaper;
import com.meida.module.user.client.entity.AppUser;
import org.springframework.stereotype.Component;

/**
 * 后台试卷
 *
 * @author zyf
 */
@Component
public class BusTestPaperListHandler implements PageInterceptor<BusTestpaper> {

    @Override
    public void prepare(CriteriaQuery<BusTestpaper> cq, PageParams pageParams, EntityMap params) {
        cq.clear();
        cq.select(BusTestpaper.class, "testpaperId", "beginYear", "endYear", "courseName", "professorName", "state", "createTime");
        cq.select(AppUser.class, "userName", "nickName", "mobile");
        cq.select(BusTerm.class, "termName");
        cq.like(BusTestpaper.class, "courseName");
        cq.like(BusTestpaper.class, "professorName");
        cq.like(AppUser.class, "userName");
        cq.like(AppUser.class, "nickName");
        cq.like(AppUser.class, "mobile");
        cq.createJoin(AppUser.class).setMainField("userId").setJoinField("userId");
        cq.createJoin(BusTerm.class).setMainField("termId").setJoinField("termId");
    }
}